import http from '@/utils/request'
import throttleRequest from '@/components/storybook/utilties/throttleRequest'
import store from '@/store'

const apiBefore = 'web/reports'
const jiraApiBefore = 'web/data-jira-api'
const options = {
  cache: {
    enable: true,
    timeout: 8 * 1000,
    failedReq: true
  },
  ignoreCancelToken: true
}
export const reports = {
  /**
   * @param {String} sql
   * @param {String} datasetId
   * @param {String} gadgetId
   * @param {Array} groupBy
   * @param {Array} summarizeBy
   */
  getFieldsListApi: params => {
    return http.post(`${apiBefore}/sys/sql/list-fields`, params)
  },
  /**
   * @param {String} sql
   * @param {String} datasetId
   * @param {String} gadgetId
   * @param {Array} groupBy
   * @param {Array} summarizeBy
   */
  getFieldsListCacheApi: params => {
    return http.post(`${apiBefore}/sys/cache/list-fields`, params)
  },
  /**
   * @param {String} sql
   * @param {String} datasetId
   * @param {String} gadgetId
   * @param {String} modelId
   * @param {Boolean} showSql
   * @param {Boolean} showQuery
   * @param {String} filter
   * post param get data for widget or bot
   */
  postInfoForGetDataApi: params => {
    return http.post(`${apiBefore}/sys/sql/query`, params)
  },
  postLogAppApi: params => {
    return http.post(`${apiBefore}/sys/access/log-app`, params)
  },
  getReportList: params => {
    return http.get(`${apiBefore}/sys/report/list`, {
      params
    })
  },
  getMyAppsListApi: () => {
    return http.get(`${apiBefore}/tenant/app/list-my-app`)
  },
  getNewAppsListApi: () => {
    return http.get(`${apiBefore}/tenant/app/list-dev`)
  },
  getAppReviewListApi: (params) => {
    return http.get(`${apiBefore}/tenant/app-approve/page-review`, {
      params
    })
  },
  getAppManagementListApi: (params) => {
    return http.get(`${apiBefore}/tenant/app/page-shelf`, {
      params
    })
  },
  getAppLogListApi: (params) => {
    return http.get(`${apiBefore}/tenant/app-approve/page-log`, {
      params
    })
  },
  getAppsMarketListApi: () => {
    return http.get(`${apiBefore}/tenant/app/list-store`)
  },
  getAppInfoApi: (params) => {
    return http.get(`${apiBefore}/tenant/app/${params.id}/info`)
  },
  getAppInfoStoreApi: (params) => {
    return http.get(`${apiBefore}/tenant/app/${params.id}/infoStore`)
  },
  getListCountApi: () => {
    return http.get(`${apiBefore}/tenant/app-approve/list-count`)
  },
  getVersionListApi: (params) => {
    return http.get(`${apiBefore}/tenant/app-approve/list-version`, {
      params
    })
  },
  getSelectListApi: (params) => {
    return http.get(`${apiBefore}/tenant/app/version-select`, {
      params
    })
  },
  getFilterListApi: params => {
    return http.post(`${apiBefore}/sys/filter/list`, params)
  },
  postUpdateAllApi: params => {
    return http.post(`${apiBefore}/tenant/app/upgrade`, params)
  },
  postDefaultInstallApi: params => {
    return http.post(`${apiBefore}/tenant/app/default-install`, params)
  },
  postFilterApi: params => {
    return http.post(`${apiBefore}/sys/filter/save`, params)
  },
  putFilterApi: params => {
    return http.put(`${apiBefore}/sys/filter/${params.id}/update`, params)
  },
  putDatasetFilterApi: (id, params) => {
    return http.put(`${apiBefore}/sys/dataset/${id}/updateDataFilter`, params)
  },
  putDatasetSortApi: (id, params) => {
    return http.put(`${apiBefore}/sys/dataset/${id}/updateDataSort`, params)
  },
  getFilterInfoApi: params => {
    return http.get(`${apiBefore}/sys/filter/${params.id}/info`, {
      params
    })
  },
  getFilterDetailApi: params => {
    return http.post(`${apiBefore}/sys/filter/detail`, params)
  },
  postAddAppsApi: params => {
    return http.post(`${apiBefore}/tenant/app/insert`, params)
  },
  postCloneAppsApi: params => {
    return http.post(`${apiBefore}/tenant/app/clone`, params)
  },
  getNextTicketAppList: () => {
    let params = {
      appType: 'nextTicket'
    }
    return http.get(`${apiBefore}/tenant/app/nextTicketAppList`, { params })
  },
  putUpdateAppsApi: params => {
    return http.put(`${apiBefore}/tenant/app/update`, params)
  },
  putBatchFilterApi: (pageId, params) => {
    return http.post(`${apiBefore}/sys/filter/updateList/${pageId}`, params)
  },
  /**
   * @param {String} gadgetId
   * @param {String} type
   * @param {String} id
   * post param for delete filter
   */
  deleteFilterApi: params => {
    return http.post(`${apiBefore}/sys/filter/delete`, params)
  },
  postPublishAppsApi: params => {
    return http.post(`${apiBefore}/tenant/app/submit-on`, params)
  },
  postIssueAppsApi: params => {
    return http.post(`${apiBefore}/tenant/app-approve/approve`, params)
  },
  postRefuseAppsApi: params => {
    return http.post(`${apiBefore}/tenant/app-approve/refuse`, params)
  },
  postOnOffAppsApi: params => {
    return http.post(`${apiBefore}/tenant/app/on-off-shelf`, params)
  },
  postAddToMyAppsApi: params => {
    return http.post(`${apiBefore}/tenant/app/install`, params)
  },
  postCancelAppsApi: params => {
    return http.post(`${apiBefore}/tenant/app/submit-off`, params)
  },
  postValidateNameApi: params => {
    return http.post(`${apiBefore}/tenant/app/validate`, params)
  },
  deleteAppsApi: params => {
    return http.delete(`${apiBefore}/tenant/app/${params.id}/delete`)
  },
  deleteMyAppsApi: params => {
    return http.post(`${apiBefore}/tenant/app/uninstall`, params)
  },
  // model
  getReportSettingInfo: params => {
    return http.get(`${apiBefore}/sys/model/info`, {
      params
    })
  },
  clearReportCacheApi: params => {
    return http.get(`${apiBefore}/sys/memoryCache/refreshAllTenantCache/${params.type}`)
  },
  getAllMaterialList: () => {
    return http.get(`${apiBefore}/sys/dataset/listAllMaterialView`)
  },
  postReportSetting: params => {
    return http.post(`${apiBefore}/sys/model/save`, params)
  },
  postRefreshMaterialized: params => {
    return http.post(`${apiBefore}/sys/dataset/refresh`, params)
  },
  postAllRefreshMaterialized: params => {
    return http.post(`${apiBefore}/sys/materialized-view/refresh`, params)
  },
  delReportSetting: (params, resourceType) => {
    return http.delete(`${apiBefore}/sys/model/${params.id}/disable`, {
      params: {
        resourceType
      }
    })
  },
  getReportDataInfo: params => {
    return http.post(`${apiBefore}/sys/model/sql`, params, {}, {
      customRequest: throttleRequest
    })
  },
  getReportGridDataInfo: params => {
    return http.post(`${apiBefore}/sys/model/sql`, params, {}, {
      ...options
    })
  },
  postModelGetData: params => {
    return http.post(`${apiBefore}/sys/model/data`, params)
  },
  getReportDataListApi: params => {
    return http.get(`${apiBefore}/sys/model/list`, {
      params
    })
  },
  getReportDataNewCardListApi: params => {
    return http.post(`${apiBefore}/sys/model/new-card-list`, params)
  },
  getReportWidgetListApi: params => {
    return http.get(`${apiBefore}/sys/model/simple-list`, {
      params
    })
  },
  getHistoryVersionsListApi: params => {
    return http.get(`${apiBefore}/sys/updateRecord/list`, {
      params
    })
  },
  useHistoryVersionApi: (id, params) => {
    return http.post(`${apiBefore}/sys/updateRecord/reset/${id}`, params)
  },
  putReportsSettingApi: params => {
    return http.put(`${apiBefore}/sys/model/update-report`, params)
  },
  snapshotUpdate: params => {
    return http.put(`${apiBefore}/sys/snapshot/update`, params)
  },
  getSnapshotData: params => {
    return http.get(`${apiBefore}/sys/snapshot/info`, { params })
  },
  saveSnapshotData: params => {
    return http.post(`${apiBefore}/sys/snapshot`, params)
  },
  snapshotRefresh: params => {
    return http.put(`${apiBefore}/sys/snapshot/refresh`, params)
  },
  getSnapshotUpdateHistory: params => {
    return http.get(`${apiBefore}/sys/snapshot/log`, {params})
  },
  postWidgetCloneDataApi: params => {
    return http.post(`${apiBefore}/sys/model/clone`, params)
  },
  // dataset
  getReportDatasetListApi: params => {
    return http.get(`${apiBefore}/sys/dataset/simple-list`, {
      params
    })
  },
  getMaterializedviewListApi: () => {
    return http.get(`${apiBefore}/sys/materialized-view/list`)
  },
  getReportDatasetInfoApi: id => {
    return http.get(`${apiBefore}/sys/dataset/${id}/info`)
  },
  getReportDatasetDataApi: (id, params) => {
    return http.get(`${apiBefore}/sys/dataset/${id}/data?${params}`)
  },
  postReportDatasetApi: params => {
    return http.post(`${apiBefore}/sys/dataset`, params)
  },
  putReportDatasetApi: (id, params) => {
    return http.put(`${apiBefore}/sys/dataset/${id}/update`, params)
  },
  delReportDatasetApi: params => {
    return http.delete(`${apiBefore}/sys/dataset/${params.id}/delete`, params)
  },
  getDataClearningLogApi: (params, config = {}) => {
    return http.get(`${apiBefore}/sys/dataset/log/page`, {
      params,
      ...config
    })
  },
  // reports
  getReportsListApi: params => {
    return http.get(`${apiBefore}/sys/report/list`, {
      params
    })
  },
  getReportsInfoApi: id => {
    return http.get(`${apiBefore}/sys/report/${id}/info`)
  },
  postReportsApi: params => {
    return http.post(`${apiBefore}/sys/report`, params)
  },
  putReportsApi: (id, params) => {
    return http.put(`${apiBefore}/sys/report/${id}/update`, params)
  },
  delReportsApi: params => {
    return http.delete(`${apiBefore}/sys/report/delete/`, params)
  },
  delReportsForPageheaderApi: params => {
    return http.delete(`${apiBefore}/sys/report/${params.id}/delete`)
  },
  cloneReportsApi: params => {
    return http.post(`${apiBefore}/sys/report/clone/${params.reportId}`, params)
  },
  cloneByTenantCodeApi: params => {
    return http.post(`${apiBefore}/sys/report/cloneByTenantCode`, params)
  },
  postDatasetCreateContentAPI: params => {
    return http.post(`${apiBefore}/sys/materialized-view/new`, params)
  },
  postAddDatasetCreateContentAPI: params => {
    return http.post(`${apiBefore}/sys/materialized-view/update`, params)
  },
  // model gadgetid serarch report
  getReportByModelListApi: params => {
    return http.get(
      `${apiBefore}/dashboard-report-model-dataset-rel/list-report-by-model`, {
        params
      }
    )
  },

  getModelByDatasetContentApi: params => {
    return http.get(`${apiBefore}/sys/materialized-view/content`, {
      params
    })
  },

  deletMematerializedviewApi: params => {
    return http.delete(`${apiBefore}/sys/materialized-view/delete`, {
      params
    })
  },
  checkSql: params => {
    return http.post(`${apiBefore}/sys/sql/checkSql`, params)
  },
  parseFilterApi: params => {
    return http.post(`${apiBefore}/sys/sql/parse-filter`, params)
  },
  /**
   * @param {String} gadgetId
   * @param {String} drillThrough
   * post param get data for  drill through info value
   */
  getDrillThroughDataInfo: params => {
    return http.post(`${apiBefore}/sys/sql/query`, params)
  },
  // check name
  postCheckNameApi: params => {
    return http.post(`${apiBefore}/sys/sql/checkName`, params)
  },
  // Query
  getQueryDataListApi: params => {
    return http.get(`${apiBefore}/sys/query/simple-list`, {
      params
    })
  },
  getQueryInfoApi: params => {
    return http.get(`${apiBefore}/sys/query/${params.id}/info`, {
      params
    })
  },
  getCloneLayerApi: params => {
    return http.get(`${apiBefore}/sys/query/clone/${params.id}`)
  },
  saveQueryInfoApi: params => {
    return http.post(`${apiBefore}/sys/query/save`, params)
  },
  updateQueryInfoApi: params => {
    return http.put(`${apiBefore}/sys/query/${params.id}/update`, params)
  },
  deleteQueryInfoApi: params => {
    return http.post(`${apiBefore}/sys/query/delete`, params)
  },
  getDashboardLayout: (params, sourceTenantCode) => {
    if(params.businessId === 'home' && store.state.siteWebConfig.homePage){
      params.businessId = store.state.siteWebConfig.homePage
    }
    return http.get(`${apiBefore}/sys/dashboard/business-id/${params.businessId}`, {
      headers: {
        'sourceTenantCode': sourceTenantCode || ''
      }
    })
  },
  getJsonFormListApi: (params) => {
    return http.get(`${apiBefore}/tenant/form`, {
      params
    })
  },
  getFormDataListApi: (params) => {
    return http.get(`${apiBefore}/tenant/form/data`, {
      params
    })
  },
  getjsonDataApi: (params) => {
    return http.get(`${apiBefore}/tenant/form/public/${params.formCode}`)
  },
  getjsonDataApiFromId: (params) => {
    return http.get(`${apiBefore}/tenant/form/public/data/${params.id}`)
  },
  getFormDataApi: (params) => {
    return http.get(`${apiBefore}/tenant/form/data/${params.id}`)
  },
  getCheckFromNameApi: (params) => {
    return http.get(`${apiBefore}/tenant/form/check/`, {
      params
    })
  },
  addOrUpdateFormApi: params => {
    return http.post(`${apiBefore}/tenant/form`, params)
  },
  addOrUpdateFormDataApi: params => {
    return http.post(`${apiBefore}/tenant/form/data`, params)
  },
  getFormDataApiValid: params => {
    return http.post(`${apiBefore}/sys/share/valid`, params)
  },
  deleteFormApi: params => {
    return http.delete(`${apiBefore}/tenant/form/${params.formCode}`)
  },
  deleteFormDataApi: params => {
    return http.delete(`${apiBefore}/tenant/form/data/${params.id}`)
  },
  deleteFormMultiple: params => {
    return http.delete(`${apiBefore}/tenant/form/data/del`, { data: params })
  },
  getFormDataInfo: params => {
    return http.get(`${apiBefore}/tenant/form/${params.formCode}`)
  },
  putChecklistApi: params => {
    return http.put(`/web/notice/tenant/task`, params)
  },
  // Slicer
  getSlicerListApi: params => {
    return http.post(`${apiBefore}/sys/model/slicer-list`, params)
  },
  getIntegrationSlicerListApi: params => {
    return http.post(`${apiBefore}/sys/model/slicer-integration-list`, params)
  },
  // getWidgetSlicerListApi API need filter id = '1'
  getWidgetSlicerListApi: params => {
    return http.post(`${apiBefore}/sys/query/widget-slicers`, params)
  },
  formlistShareUrl: params => {
    return http.post(`${apiBefore}/sys/share`, params)
  },
  getformlistShareData: params => {
    return http.get(`${apiBefore}/sys/share/resource/${params}`)
  },

  shareUserList: (id) => {
    return http.get(`${apiBefore}/sys/share/record/list/${id}`)
  },
  shareUserDataList: (params) => {
    return http.post(`${apiBefore}/sys/sql/query`, params)
  },
  saveEmailsData: (params) => {
    return http.post(`/web/um/sys/tenant/setting/save`, params)
  },
  deleteShareUser: (id) => {
    return http.delete(`${apiBefore}/sys/share/record/${id}/delete`)
  },
  // dataset layer
  getDatasetLayerList: params => {
    return http.get(`${apiBefore}/sys/datasetlayer/list`, {
      params
    })
  },
  getDatasetLayerListPage: params => {
    return http.get(`${apiBefore}/sys/datasetlayer/page`, {
      params
    })
  },
  getDatasetLayerInfo: params => {
    return http.get(`${apiBefore}/sys/datasetlayer/${params.id}/info`, params)
  },
  addDatasetLayerApi: params => {
    return http.post(`${apiBefore}/sys/datasetlayer`, params)
  },
  updateDatasetLayerApi: params => {
    return http.put(`${apiBefore}/sys/datasetlayer/${params.id}/update`, params)
  },
  delDatasetLayerApi: params => {
    return http.delete(`${apiBefore}/sys/datasetlayer/${params.id}/delete`, params)
  },
  checkSysDatasetKeyApi: params => {
    return http.post(`${apiBefore}/sys/dataset/checkDatasetKey`, params)
  },
  postSendNowApi: params => {
    return http.post(`${apiBefore}/sys/share/runonce`, params)
  },
  postSendMeApi: params => {
    return http.post(`${apiBefore}/sys/share/me`, params)
  },
  updateDatasetInfoForKeyApi: params => {
    return http.put(`${apiBefore}/sys/dataset/${params.datasetKey}/updateByDatasetKey`, params)
  },
  saveLayoutSettingApi: params => {
    return http.put(`${apiBefore}/sys/dashboard/${params.businessId}/updateDashboardSetting`, params)
  },
  getDataserInfoFromKeyApi: params => {
    return http.get(`${apiBefore}/sys/dataset/${params.datasetKey}/infoByDatasetKey`, params)
  },
  // dashboard
  saveDashboardLayout: params => {
    return http.post(`${apiBefore}/sys/dashboard/save`, params)
  },
  updateDashboardLayout: params => {
    return http.put(`${apiBefore}/sys/dashboard/update`, params)
  },
  postUpdateHomePage: params => {
    return http.post(`${apiBefore}/sys/dashboard/updateHomePage`, params)
  },
  // check Jira Number
  checkJiraNumber: params => {
    const {
      issueIdOrKey
    } = params
    return http.get(`${jiraApiBefore}/issue/comment/exist?issueIdOrKey=${issueIdOrKey}`)
  },
  createMcsIssue: params => {
    return http.post(`${jiraApiBefore}/issue/createMcsIssue`, params)
  },
  postBatchGenerateDataset: params => {
    return http.post(`${apiBefore}/sys/dataset/batchInsert`, params)
  },
  getDatasetListForApi: params => {
    return http.get(`${apiBefore}/sys/dataset/list`, {
      params
    })
  },
  refreshDataSetApi: params => {
    return http.get(`${apiBefore}/sys/dataset/refreshData`, {
      params
    })
  },
  tags: params => {
    return http.get(`${apiBefore}/sys/tagResource/select`, params)
  },
  getShareLogList: params => {
    return http.get(`${apiBefore}/sys/share/log`, {params})
  },
  quickFiltersTotal: (params, urlType) => {
    if (urlType === 'bot') {
      return http.post(`web/bots/sys/${urlType}/tag-list`, params)
    }
    return http.post(`${apiBefore}/sys/${urlType}/tag-list`, params)
  },
  quickFilters: params => {
    return http.post(`${apiBefore}/sys/quickFilter/list`, params)
  },
  saveFavorite: params => {
    return http.post(`${apiBefore}/sys/userFavorite `, params)
  },
  removeFavorite: (id, type) => {
    return http.delete(`${apiBefore}/sys/userFavorite/delete/${type}/${id}`)
  },
  disposeQuickFilter: params => {
    return http.post(`${apiBefore}/sys/quickFilter/save`, params)
  },
  deleteQuickFilter: id => {
    return http.delete(`${apiBefore}/sys/quickFilter/${id}/delete`)
  },
  syncLog: ({
    id
  }) => {
    return http.post(`${apiBefore}/sys/dataset/log/list?id=${id}`)
  },
  queryCleaning: (id, config = {}) => {
    return http.get(`${apiBefore}/sys/dataset/log/queryCleaning?id=${id}`, config)
  },
  lastUpdateTime: ({
    id
  }) => {
    return http.get(`${apiBefore}/sys/dataset/log/lastUpdateTime?id=${id}`)
  },
  datasetStart: ({
    id
  }) => {
    return http.get(`${apiBefore}/sys/dataset/log/datasetStart?id=${id}`)
  },
  noIntegrations: (params, type) => {
    if (type === 'widget') {
      return http.post(`${apiBefore}/sys/model/noIntegrationList`, params)
    }
    if (type === 'dataset') {
      return http.post(`${apiBefore}/sys/dataset/noIntegrationList`, params)
    }
    if (type === 'dashboard') {
      return http.post(`${apiBefore}/sys/dashboard/noIntegrationList`, params)
    }
    return http.post(`web/${type}s/sys/${type}/noIntegrationList`, params)
  },
  deletePrebuilt: ({
    id,
    checkbox
  }) => {
    return http.delete(`${apiBefore}/tenant/app/prebuiltDelete?id=${id}&checkbox=${checkbox}`)
  },
  saveOrUpdatePresentInfo: params => {
    return http.post(`${apiBefore}/tenant/collection/save`, params)
  },
  getGroupList: params => {
    return http.get(`${apiBefore}/tenant/collection/list`, { params })
  },
  getGroupListTv: params => {
    return http.get(`${apiBefore}/tenant/collection/${params.tenantCode}`, { params })
  },
  getGroupInfo: params => {
    return http.get(`${apiBefore}/tenant/collection/${params.id}/info`, { params })
  },
  delGroupItem: params => {
    return http.delete(`${apiBefore}/tenant/collection/${params.id}/delete`, { params })
  },
  getReportCardList: params => {
    return http.post(`${apiBefore}/sys/report/card-list`, params, {}, { cache: { enable: false } })
  },
  updateFormDataFromKey: params => {
    return http.post(`${apiBefore}/tenant/form/update-form-data`, params)
  },
  payUserInfo: params => {
    return http.get(`${apiBefore}/app/user/appUserInfo`, { params })
  },
  addPayUserInfo: params => {
    return http.post(`${apiBefore}/app/user/insert`, params)
  },
  putPayUserInfo: params => {
    return http.put(`${apiBefore}/app/user/update`, params)
  },
  modelInfo: params => {
    return http.get(`${apiBefore}/sys/model/modelInfo`, { params })
  },
  paywallFreeAccountList: params => {
    return http.get(`${apiBefore}/sys/paywall/setting/freeAccountList`, { params }, { cache: { enable: false } })
  },
  paywallTenantList: params => {
    return http.get(`${apiBefore}/sys/paywall/setting/tenantList`, { params }, { cache: { enable: false } })
  },
  paywallFreeAccountCreated: params => {
    return http.post(`${apiBefore}/sys/paywall/setting`, params, '', { cache: { enable: false } })
  },
  paywallTenantCreated: params => {
    return http.post(`${apiBefore}/sys/paywall/setting/insertBatch`, params, '', { cache: { enable: false } })
  },
  paywallFreeAccountUpdate: params => {
    return http.put(`${apiBefore}/sys/paywall/setting/update`, params, '', { cache: { enable: false } })
  },
  paywallFreeAccountUpdateArr: params => {
    return http.put(`${apiBefore}/sys/paywall/setting/updateByIds`, params, '', { cache: { enable: false } })
  },
  paywallFreeAccountDelete: params => {
    return http.delete(`${apiBefore}/sys/paywall/setting`, {
      data: params
    }, { cache: { enable: false } })
  },
  publicApiList: () => {
    return http.get(`${apiBefore}/tenant/public-api/list`)
  },
  publicApiRefresh: (param) => {
    return http.post(`${apiBefore}/tenant/public-api/${param.id}/refresh`)
  },
  publicAddKey: (params) => {
    return http.post(`${apiBefore}/tenant/public-api/add`, params)
  },
  publicRemoveKey: (params) => {
    return http.delete(`${apiBefore}/tenant/public-api/${params.id}/del`)
  },
  publicRemoveApi: (params) => {
    return http.delete(`${apiBefore}/tenant/public-rec/del/${params.apiId}/${params.id}`)
  },
  getPublicRec: (params) => {
    return http.get(`${apiBefore}/tenant/public-rec/list/${params.resourceType}`, {params})
  },
  publicSaveRec: (params) => {
    return http.post(`${apiBefore}/tenant/public-rec/save`, params)
  },
  publicSaveRecs: (params) => {
    return http.post(`${apiBefore}/tenant/public-rec/batch/${params.apiId}/${params.type}`, params.data)
  },
  datasetList: (params) => {
    return http.post(`${apiBefore}/sys/dataset/card-list`, params)
  },
  widgetList: (params) => {
    return http.post(`${apiBefore}/sys/model/new-card-list`, params)
  },
  botList: (params) => {
    return http.post(`web/bots/sys/bot/card-list`, params)
  },
  etlJobRunOnce: ({ id }) => {
    return http.get(`${apiBefore}/sys/etl/job/trigger?id=${id}`)
  },
  etlJobAdd: (params) => {
    return http.post(`${apiBefore}/sys/etl/job/add`, params)
  },
  etlJobDel: ({ id }) => {
    return http.delete(`${apiBefore}/sys/etl/job/${id}/del`)
  },
  etlJobFresh: (params) => {
    return http.put(`${apiBefore}/sys/etl/job/${params.id}/fresh`, params)
  },
  etlJobList: ({ id, name, tenentCode, size, current }) => {
    return http.get(`${apiBefore}/sys/etl/job/list/page?size=${size}&current=${current}${(id ? `&id=${id}` : '') + (name ? `&name=${name}` : '') + (tenentCode ? `&tenentCode=${tenentCode}` : '')}`)
  },
  getDeviceToken: () => {
    return http.get(`${apiBefore}/tenant/device/token`)
  },
  getDeviceManageList: (params) => {
    return http.get(`${apiBefore}/tenant/device/pageList`, {params})
  },
  getDeviceManageListAll: () => {
    return http.get(`${apiBefore}/tenant/device/items`)
  },
  changeDeviceInfo: (params) => {
    return http.put(`${apiBefore}/tenant/device`, params)
  },
  deleteDevice: (params) => {
    return http.delete(`${apiBefore}/tenant/device/del/${params.id}`)
  },
  getDeviceLog: (params) => {
    return http.get(`${apiBefore}/tenant/device/log/${params.deviceCode}`, { params })
  },
  getSmtpList: (params) => {
    return http.get(`${apiBefore}/tenant/smtp/items/page`, { params })
  },
  getSmtpItems: () => {
    return http.get(`${apiBefore}/tenant/smtp/items`)
  },
  getSmtpConfirm: (params) => {
    return http.get(`${apiBefore}/tenant/smtp/confirm`, { params })
  },
  getSmtpCheck: (params) => {
    return http.get(`${apiBefore}/tenant/smtp/check`, { params })
  },
  deleteSmtp: (params) => {
    return http.delete(`${apiBefore}/tenant/smtp/data/del`,  {
      data: params
    })
  },
  postEmailVerify: (params) => {
    return http.post(`${apiBefore}/tenant/smtp/mail/verify`, params)
  },
  getDashboardName: (params) => {
    return http.post(`${apiBefore}/tenant/device/rec/names`, params)
  },
  shareToDevice: (params) => {
    return http.post(`${apiBefore}/tenant/device/share`, params)
  },
  addDashboardToTv: (params) => {
    return http.put(`${apiBefore}/tenant/device/${params.deviceId}/loop`, params.ids)
  },
  getOptionsTextColor: () => {
    return http.get(`${apiBefore}//sys/dataset/textColor`)
  }
}
